using System;
using System.Collections.Generic;
using System.Text;
using Jbe.TestSuite.TestDevices.Interface;
using Jbe.TestSuite.Infrastructure.Interface;
using Microsoft.Practices.Composite.Regions;
using Jbe.TestSuite.TestDevices.FunctionGenerator.Interface;
using Jbe.Composite.Extensions;

namespace Jbe.TestSuite.TestDevices.FunctionGenerator.ControlView.Services
{
    internal class ViewControllerFactory : IControlViewFactory 
    {
        private readonly IApplicationContainer container;
        private readonly IRegionManager regionManager;
        private int controlViewCount = 0;


        public ViewControllerFactory(IApplicationContainer container, IRegionManager regionManager)
        {
            this.container = container;
            this.regionManager = regionManager;
        }


        public string ProfileName
        {
            get { return ProfileNames.FunctionGenerator; }
        }


        public IControlView Create(IDevice device)
        {
            controlViewCount++;
            IFunctionGenerator functionGenerator = ((IFunctionGeneratorProvider)device).FunctionGenerator;
            
            ViewController controller = new ViewController(container, regionManager, device, functionGenerator);
            controller.Name = String.Format("{0:00} {1}", controlViewCount, ProfileName);
            
            return controller;
        }
    }
}
